package com.zhss.designpattern.singleton;import com.sun.org.apache.xalan.internal.xsltc.dom.SingletonIterator;/** * @Author: Beating Pupils * @Date: 2020/11/1 22:26 * @Description: 饿汉单例模式:一开始就创建单例，不管是否调用 */public class HungrySingleton {    public static void main(String[] args) {        Singleton instance = Singleton.getInstance();    }    public static class Singleton {        //1.创建一个静态的不可修改的singleton实例        private final static Singleton instance = new Singleton();        //2.修改构造方法为私有方法        private Singleton() {        }        //3.暴露一个静态方法，返回唯一的静态实例        public static Singleton getInstance() {            return instance;        }    }}